package com.hulk.ratel.common.constant.enums;

import com.google.common.base.Objects;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum BussErrCode {

    S_0(0, "成功"),
    S_200(200, "成功"),
    S_10(10, "补单成功"),
    S_20(20, "交易撤销成功"),


    S_500(500, "unknown error"),

    E_100001(100001, "报文不合法"),
    E_100002(100002, "合作方无法识别"),
    E_100003(100003, "报文签名校验不通过"),
    E_100004(100004, "交互解密异常"),
    E_100005(100005, "报文签名校验不通过"),
    E_100006(100006, "转换数据错误"),
    E_100007(100007, "解包失败"),
    E_100008(100008, "MAC校验失败"),
    E_100009(100009, "该交易维护中,请稍等再试(交易关闭)"),
    E_100010(100010, "合作方公钥未提供"),
    E_100011(100011, "解密AES密钥时失败"),
    E_100012(100012, "报文解密失败"),
    E_100013(100013, "请求流水号超长"),
    E_100014(100014, "业务类型不合法"),
    E_100015(100015, "AES密钥不合法"),
    E_100016(100016, "请求参数不合法"),
    E_100017(100017, "支付机构密钥不存在"),
    E_100018(100018, "合作方交互超时"),
    E_100019(100019, "平台方公钥未提供"),
    E_100020(100020, "平台方私钥钥未提供"),
    E_100021(100021, "交易代码不正确"),


    E_200106(200106, "订单号重复"),
    E_200105(200105, "支付机构无法识别"),
    E_200153(200153, "合作方类型无法识别"),





    E_900001(900001, "系统维护中"),
    E_900002(900002, "系统错误  "),
    E_900003(900003, "交易超时 "),
    E_900004(900004, "支付机构不可用"),
    E_900005(900005, "资源繁忙 (流控)"),
    E_900006(900006, "支付机构异常 "),
    E_900007(900007, "非法数据A "),
    E_900008(900008, "非法数据B "),
    E_900009(900009, "数据库资源忙 "),
    E_900010(900010, "暂未开通权限"),
    E_900011(900011, "未找到路由信息"),
    E_900013(900013, "下游交易超时 "),
    E_900014(900014, "上游交易超时 "),
    E_900015(900015, "待用户支付确认"),

    E_999999(999999, "未知异常");

    private int errCode;
    private String errDesc;



    public static String explain(int errcode) {
        for (BussErrCode bussErrorCode : BussErrCode.values()) {
            if (Objects.equal(errcode, bussErrorCode.errCode)) {
                return bussErrorCode.errDesc;
            }
        }
        return "";
    }



}
